package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Classify;
import com.example.entity.vo.ClassifyVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-09-05
 */
@Mapper
public interface ClassifyMapper extends BaseMapper<Classify> {
    @Select("SELECT p.classify_id AS parent_id, p.classify_name AS parent_name,c1.classify_id AS child1_id,c1.classify_name AS child1_name,c1.classify_image_url AS child1_image_url,c2.classify_id AS child2_id,c2.classify_name AS child2_name,c2.classify_image_url AS child2_image_url FROM classify AS p LEFT JOIN classify AS c1 ON p.classify_id = c1.classify_parent LEFT JOIN classify AS c2 ON c1.classify_id = c2.classify_parent WHERE p.classify_parent = 0")
    List<ClassifyVo> selectClassifyId();
}
